package com.my.db.test.mybatis.enums.defal;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author timo 2021/3/29
 */
public class CustomEnums{

    public interface IEnum {
        EnumItem getEnumItem();
    }
    @AllArgsConstructor
    public enum LangEnum implements  IEnum{
        Chinese("zh_CN"),
        English("en-uk");
        private EnumItem item=new EnumItem();
        LangEnum(String itemValue) {
            item.setItemValue(itemValue);
        }
        @Override
        public EnumItem getEnumItem() {
            return item;
        }
    }
    //region SexEnum
    @AllArgsConstructor
    @Getter
    public enum SexEnum implements IEnum  {
        WOMAN(0, "女"),
        MAN(1, "男");
        @EnumValue
        private final Integer id;
        @JsonValue
        private final String name;
        @Override
        public EnumItem<Integer> getEnumItem() {
            return new EnumItem(id,name,this.ordinal());
        }
    }
    //endregion

    //国际化如何处理
    //region IsDeleteEnum
    public enum IsDeleteEnum implements IEnum  {
        No(0d, "否","No","0"),
        Yes(1.3d, "是","Yes","1.3");

        private EnumItem item=new EnumItem();

        IsDeleteEnum(Double itemKey,String itemCN,String itemEN,String itemValue) {
            item.setItemKey(itemKey);
            item.setItemCN(itemCN);
            item.setItemEN(itemEN);
            item.setItemValue(itemValue);

        }

        @Override
        public EnumItem<Double> getEnumItem() {
            return item;
        }
    }
    //endregion

    @Getter
    @AllArgsConstructor
    public enum QuestionType implements  IEnum{
        SINGLE_QUESTION(1, "单选题"),
        MULTIPLE_QUESTION(2, "多选题"),
        FILL_QUESTION(3, "填空题"),
        SYNTHESIS_QUESTION(4, "综合题"),
        INDEFINITE_ITEM_QUESTION(5, "不定项题"),
        CALCULATION_QUESTION(7, "计算题"),
        JUDGMENT_QUESTION(6, "判断题");
        @EnumValue
        private int value;
        @JsonValue
        private String name;

        @Override
        public EnumItem<Integer> getEnumItem() {
            return new EnumItem(value,name,this.ordinal());
        }
    }
}
